package com.scalar.chiptrack.adaptor.carsem;

import com.scalar.chiptrack.jobs.JobHandler;
import com.scalar.chiptrack.adaptor.AdaptorConstants;
import com.scalar.chiptrack.adaptor.AssemblyLot;
import com.scalar.chiptrack.adaptor.InventoryLot;
import com.scalar.chiptrack.adaptor.TestLot;
import com.scalar.chiptrack.adaptor.AdaptorUtils;
import com.scalar.chiptrack.adaptor.utils.ParserResult;
import com.scalar.chiptrack.adaptor.utils.Parser;
import com.scalar.chiptrack.adaptor.utils.ParserFactory;
import com.scalar.chiptrack.adaptor.utils.JXLXLSParserImpl;
import com.scalar.chiptrack.adaptor.dao.ShippedLotDAO;
import com.scalar.chiptrack.adaptor.dao.InventoryLotDAO;
import com.scalar.chiptrack.adaptor.dao.TestAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.AssemblyAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.AdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.AdaptorRunInfo;
import com.scalar.chiptrack.adaptor.dao.NewAdaptorDAO;
import com.scalar.chiptrack.utils.Logger;
import com.scalar.chiptrack.utils.StringUtils;
import com.scalar.chiptrack.operations.process.dao.NewProductDAO;
import com.scalar.chiptrack.operations.process.ParameterTypes;
import com.scalar.ScalarException;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: munugoti
 * Date: 16 Dec, 2009
 * Time: 8:50:15 PM
 */
public class CarsemDataParser extends JobHandler implements AdaptorConstants
{
    private HashMap<String, AssemblyLot> m_assemblyDataMap = new HashMap<String, AssemblyLot>();
    private HashMap<String, InventoryLot> m_dieBankDataMap  = new HashMap<String, InventoryLot>();
    private HashMap<String, InventoryLot> m_backGrindDataMap  = new HashMap<String, InventoryLot>();
    private HashMap<String, TestLot> m_testDataMap          = new HashMap<String, TestLot>();
    private HashMap<String, InventoryLot> m_preTestDataMap	= new HashMap<String, InventoryLot>();
    private HashMap<String, ArrayList> m_partNumberMap	= new HashMap<String, ArrayList>();

    private Logger m_parserLogger       = null;
    private String m_dataOutputDir      = null;

    public  CarsemDataParser() throws ScalarException
    {
        try
        {
            m_dataOutputDir = AdaptorUtils.getDataOutputDir( VENDOR_NAME_CARCEM , LOCATION_TYPE_ASSEMBLY );
            
            if ( m_dataOutputDir != null )
            {
                AdaptorUtils.makeAllAdaptorDirs( m_dataOutputDir );

                m_parserLogger= AdaptorUtils.getDataParserLogger( m_dataOutputDir,VENDOR_NAME_CARCEM );

                AdaptorUtils.setLogger( m_parserLogger );
                ShippedLotDAO.setLogger( m_parserLogger);
                InventoryLotDAO.setLogger(m_parserLogger);
                TestAdaptorDAO.setLogger( m_parserLogger);
                AssemblyAdaptorDAO.setLogger( m_parserLogger );
            }
        }
        catch ( Exception se )
        {
            log( "ERROR!! ERROR!! ERROR!! Exception while loading AMKOR_PH output directory details from database, Exception: " + se );
            System.out.println( "ERROR!! ERROR!! ERROR!! Exception while loading AMKOR_PH output directory details from database, Exception: " + se );
        }
    }
    public static void main( String args[] ) throws Exception
    {
        try
        {
            new CarsemDataParser().execute();
        }
        catch ( Exception e )
        {
            throw e;
        }
    }
    public void execute() throws Exception
    {
        AdaptorUtils.printHeader( VENDOR_NAME_CARCEM, CONSTANT_PARSER );

        File doneDestDir = new File( m_dataOutputDir + "/done" );
        File dataoutDir  = new File( m_dataOutputDir );

        File[] fileList = dataoutDir.listFiles();

        if ( ( fileList == null ) || (fileList.length <= 3))
        {
            log("No file found in directory: " + dataoutDir);
            System.out.println("No file found in directory: " + dataoutDir );
            throw new ScalarException("No file found in directory: " + dataoutDir+ "----\n\n" );
        }

        ArrayList<File> successFileList = new ArrayList<File>();

        boolean success = false;

        for ( int i = 0; i < fileList.length; i++ )
        {
            if ( fileList[i].isDirectory() )
            {
                continue;
            }

            try
            {
                if ( fileList[i].getName().startsWith( CarsemAdaptor.FILE_NAME_WIP )  || fileList[i].getName().indexOf( CarsemAdaptor.FILE_NAME_WIP )  != -1)
                {
                    parseWipReport( fileList[i].getAbsolutePath() );

                    successFileList.add(fileList[i]);
                }
                if ( fileList[i].getName().startsWith( CarsemAdaptor.FILE_NAME_TEST_WIP )  || fileList[i].getName().indexOf( CarsemAdaptor.FILE_NAME_TEST_WIP )  != -1)
                {
                     parseTestWipReport( fileList[i].getAbsolutePath() );

                     successFileList.add(fileList[i]);
                }
                /*if ( fileList[i].getName().startsWith( CarsemAdaptor.FILE_NAME_YIELD )  || fileList[i].getName().indexOf( CarsemAdaptor.FILE_NAME_YIELD )  != -1)
                {

                    successFileList.add(fileList[i]);
                }*/
                success = true;
            }
            catch (Exception e)
            {
                success = false;
                log("Exception while parsing file: " + fileList[i].getAbsolutePath() + "\nException: " + e);
                e.printStackTrace();
                throw e;
            }
        }

        try
        {
            // Save Wafer Store Information
            if (m_backGrindDataMap.isEmpty() == false)
            {
                log(" Updating Back Grind Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_backGrindDataMap.values().iterator(), LOCATION_TYPE_BACK_GRIND, VENDOR_NAME_CARCEM);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_BACK_GRIND, VENDOR_NAME_CARCEM);
            }
            success = true;
            m_backGrindDataMap.clear();
            m_backGrindDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Wafer Store Lot information into database: " + se);
            throw se;
        }
        /*Updating the Die Bank Lot Information*/
        try
        {
            // Save Die Bank Information
            if (m_dieBankDataMap.isEmpty() == false)
            {
                log(" Updating Die Bank Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_dieBankDataMap.values().iterator(), LOCATION_TYPE_DIE_BANK, VENDOR_NAME_CARCEM);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_DIE_BANK, VENDOR_NAME_CARCEM);
            }
            success = true;
            m_dieBankDataMap.clear();
            m_dieBankDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Die Bank Lot information into database: " + se);
            throw se;
        }

        /*Updating the Assembly Lot Information*/
        try
        {
            // Step 2
            // Save Assembly Information
            if (m_assemblyDataMap.isEmpty() == false)
            {
                log(" Updating Assembly Lot Information");
                AssemblyAdaptorDAO.saveAssemblyLot(null, m_assemblyDataMap.values().iterator(),WIP_TYPE_ASSEMBLY, VENDOR_NAME_CARCEM);
            }
            else
            {
                AssemblyAdaptorDAO.closeAssemblyLot(null, WIP_TYPE_ASSEMBLY, VENDOR_NAME_CARCEM);
            }

            m_assemblyDataMap.clear();
            m_assemblyDataMap = null;
            success = true;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Assembly Lot information into database: " + se);
            throw se;
        }

        try
        {              
           if ( m_preTestDataMap.isEmpty() == false )
           {
               log(" Updating Class Stroe Lot Information");
               InventoryLotDAO.saveInventoryLot( null, m_preTestDataMap.values().iterator(), LOCATION_TYPE_PRE_TEST, VENDOR_NAME_CARCEM );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_PRE_TEST, VENDOR_NAME_CARCEM  );
           }
      }
      catch (ScalarException se)
      {
          success = false;
          se.printStackTrace();
          log("ERROR!! ERROR!! ERROR!! Could not update Pre Test Lot information into database: " + se);
          throw se;
      }
		try
        {
           // Saving FINAL TEST Information
           if ( m_testDataMap.isEmpty() == false )
            {
                log( " Updating Test Lot Information" );
                TestAdaptorDAO.saveTestLot( null,m_testDataMap.values().iterator(), LOCATION_TYPE_FT, VENDOR_NAME_CARCEM );
            }
            else
           {
               TestAdaptorDAO.closeTestLot( null, LOCATION_TYPE_FT, VENDOR_NAME_CARCEM );
           }

           success = true;
        }
        catch ( ScalarException se )
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Test Lot information into database: " + se );
            throw se;
        }

        // TO SEND THE NEW LOTS, NEW TRANSIT LOTS, NO PO LOTS, DISCREPANCY LOTS NOTIFICATIONS TO THE USER
        AdaptorDAO.sendAllNotifications( VENDOR_NAME_CARCEM,true, true, true );

        // To Close the Drop Out Lots
        AdaptorDAO.closeDropOutLots( VENDOR_NAME_CARCEM );

        int adaptor_id = AdaptorRunInfo.getLastRunAdaptorId( CarsemAdaptor.ADAPTOR_NAME, CONSTANT_ADAPTOR);
        // transaction 9
        try
        {
            if (success)
            {
                AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, CarsemAdaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
                System.out.println("SUCCESSFULLY UPDATED IN THE DATABASE");
            }
        }
        catch (ScalarException se)
        {
            success = false;  //As filES DATA SAVED , UPDATEING AS SUCCESS
            AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, CarsemAdaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
            log("WARNING!! WARNING!! WARNING!! Could not update Adaptor run information, Exception: " + se);
            throw se;
        }

        // Step 10
        // Move the successful files to 'done' directory
        if (success)
        {
            AdaptorUtils.moveFilesToDone( successFileList, doneDestDir);
        }
    }

    private void parseWipReport (String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ParserResult result            = null;

        InventoryLot inventoryLot  = null;
        AssemblyLot  assemblyLot   = null;
        String partNumber       = null;
        String lotNumber        = null;

        try
        {
            File detailWipFile = new File( fileName );
            if ( !detailWipFile.exists() )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            Parser parser = ParserFactory.getJXLXLSParser( detailWipFile );
            log( "\nFound " + fileName );
            log( "\nParsing the file for Wip Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for Wip Report..." );

            ((JXLXLSParserImpl)parser).setHeaderRowIdx(9);
            ((JXLXLSParserImpl)parser).setDataStartRowIdx(10);

            result = parser.parse();

            while ( result.next() )
            {
                if ( result.getString("LOTNO") != null && result.getString("LOTNO").indexOf("DEFINITIONS OF TERMS") != -1 )
                {
                    break;
                }
                String fabLotNumber     = null;
                String allWafers = null;
                partNumber = result.getString("DEVICE");
                lotNumber  = result.getString("LOTNO");

                if ( partNumber != null && partNumber.trim().length() > 0 && lotNumber != null && lotNumber.trim().length() >0 )
                {
					 String waferIds = null;
					if ( lotNumber.indexOf("@") != -1 )
                    {
                        lotNumber = lotNumber.split("@")[0];
                    }
                    if ( lotNumber.indexOf("#") != -1 )
                    {
                        lotNumber = lotNumber.split("#")[0];
					}
                   
                    if ( result.getString("WAFER ID") != null && result.getString("WAFER ID").trim().length() > 0 )
                    {
						if (result.getString("WAFER ID").trim().length() > 8   )
						{
							if ( result.getString("WAFER ID").trim().indexOf("-") != -1 )
							{								
								waferIds =  result.getString("WAFER ID").trim().split("-")[1];
								waferIds = waferIds.substring(0,2);
								//waferIds = lotNumber.split("#")[1];
							}
							
						}
						else
						{	
							waferIds = result.getString("WAFER ID").replaceAll("[a-zA-Z]", "").replaceAll(",", ";");
						}	
						if ("null".equalsIgnoreCase(waferIds) )
						{
							waferIds = "";
						}
                    }
                   
                    if ( fabLotNumber == null )
                    {
                        fabLotNumber = lotNumber;
                    }

                    if ( result.getInt("INV QTY") > 0 && "TBA".equalsIgnoreCase( result.getString("PKG") ))
                    {
                        //BACK GRIND LOTS
                        if ( result.getInt("B/G STR") > 0 )
                        {
                            inventoryLot = (InventoryLot)m_backGrindDataMap.get( partNumber + lotNumber );

                            if ( inventoryLot == null )
                            {
                                inventoryLot = new InventoryLot( VENDOR_NAME_CARCEM, LOCATION_TYPE_BACK_GRIND );
                                m_backGrindDataMap.put( partNumber + lotNumber, inventoryLot );
                            }

                            int wquantity = 0;
                            if (inventoryLot.getWaferQtyIn() != null)
                            {
                                try
                                {
                                    wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                                }
                                catch (NumberFormatException ignore) {
                                }
                                int fabProcessStepId = NewAdaptorDAO.getProcessStepId( partNumber, WIP_TYPE_FAB, WIP_TYPE_FAB );
                                int gdpw = 1;
                                try
                                {
                                    gdpw = Integer.parseInt(NewProductDAO.getProcessParameterValue( null, fabProcessStepId, ParameterTypes.grossDieWafer ) ) ;
                                }
                                catch( NumberFormatException nfe ) { gdpw = 1; }

								wquantity += (result.getInt("B/G STR") )/gdpw;
							    
                            }
                            else
                            {
                                int fabProcessStepId = NewAdaptorDAO.getProcessStepId( partNumber, WIP_TYPE_FAB, WIP_TYPE_FAB );
                                int gdpw = 1;
                                try
                                {
                                    gdpw = Integer.parseInt(NewProductDAO.getProcessParameterValue( null, fabProcessStepId, ParameterTypes.grossDieWafer ) ) ;
                                }
                                catch( NumberFormatException nfe ) { gdpw = 1; }
								wquantity = (result.getInt("B/G STR") )/gdpw;
								
                            }
                            if ( inventoryLot.getWaferId() != null )
                            {
                                allWafers = inventoryLot.getWaferId() +";" + waferIds;
                            }
                            else
                            {
                                allWafers = waferIds;
                            }
                            if (wquantity > 0 )
                            {
                                inventoryLot.setPartNumber( partNumber );
                                inventoryLot.setLotNumber( lotNumber );
                                inventoryLot.setWaferQtyIn(wquantity + "");
                                inventoryLot.setPkgType(result.getString("PKG"));
                                inventoryLot.setDateIn( StringUtils.formatDateToString( result.getDate("DATE RCVD") ) );
                                inventoryLot.setFabLotNumber( lotNumber );
                                inventoryLot.setStatus( LOT_STATUS_RUNNING );
                                inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_PROD );
                                inventoryLot.setWaferId( allWafers );
                            }
                        }
                        else
                        {
                            inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + lotNumber );

                            if ( inventoryLot == null )
                            {
                                inventoryLot = new InventoryLot( VENDOR_NAME_CARCEM, LOCATION_TYPE_DIE_BANK );
                                m_dieBankDataMap.put( partNumber + lotNumber, inventoryLot );
                            }

                            int quantity = 0;
                            int wquantity = 0;
                            if (inventoryLot.getQtyIn() != null)
                            {
                                try
                                {
                                    quantity = Integer.parseInt(inventoryLot.getQtyIn());
                                }
                                catch (NumberFormatException ignore) {
                                }
                                try
                                {
                                    wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                                }
                                catch (NumberFormatException ignore) {
                                }
                                if ( result.getInt("INV QTY") <=25)
                                {
                                    wquantity += result.getInt("WAFER QTY");
                                    int fabProcessStepId = NewAdaptorDAO.getProcessStepId( partNumber, WIP_TYPE_FAB, WIP_TYPE_FAB );
                                    int gdpw = 1;
                                    try
                                    {
                                        gdpw = Integer.parseInt(NewProductDAO.getProcessParameterValue( null, fabProcessStepId, ParameterTypes.grossDieWafer ) ) ;
                                    }
                                    catch( NumberFormatException nfe ) { gdpw = 1; }

                                    quantity += (result.getInt("INV QTY") ) * gdpw;
                                }
                                else
                                {
                                    quantity += result.getInt("INV QTY");
                                    wquantity+= result.getInt("WAFER QTY");
                                }
                            }
                            else
                            {
                                if ( result.getInt("INV QTY") <=25)
                                {
                                    wquantity = result.getInt("INV QTY");
                                    int fabProcessStepId = NewAdaptorDAO.getProcessStepId( partNumber, WIP_TYPE_FAB, WIP_TYPE_FAB );
                                    int gdpw = 1;
                                    try
                                    {
                                        gdpw = Integer.parseInt(NewProductDAO.getProcessParameterValue( null, fabProcessStepId, ParameterTypes.grossDieWafer ) ) ;
                                    }
                                    catch( NumberFormatException nfe ) { gdpw = 1; }

                                    quantity = wquantity * gdpw;
                                }
                                else
                                {
                                    wquantity = result.getInt("WAFER QTY");
                                    quantity = result.getInt("INV QTY");
                                }
                            }
                            if ( inventoryLot.getWaferId() != null )
                            {
                                allWafers = inventoryLot.getWaferId() + ";" + waferIds;
                            }
                            else
                            {
                                allWafers = waferIds;
                            }
                            if (quantity > 0 )
                            {
                                inventoryLot.setPartNumber( partNumber );
                                inventoryLot.setLotNumber( lotNumber );
                                inventoryLot.setQtyIn(quantity + "");
                                inventoryLot.setWaferQtyIn(wquantity + "");
                                inventoryLot.setPkgType(result.getString("PKG"));
                                inventoryLot.setDateIn( StringUtils.formatDateToString( result.getDate("DATE RCVD") ) );
                                inventoryLot.setFabLotNumber( lotNumber );
                                inventoryLot.setStatus( LOT_STATUS_RUNNING );
                                inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_PROD );
								if (allWafers != null && allWafers.trim().length() > 0 )
								{
									inventoryLot.setWaferId(allWafers.replaceAll("[a-zA-Z]", ""));
								}
                            }
                        }
                    }//End OF DieBank

                    if ( !"TBA".equalsIgnoreCase( result.getString("PKG") ) && ( result.getInt("QTY SHIP") > 0 || result.getInt("B/G STR") > 0 || result.getInt("SB STR") > 0 || (!"C".equalsIgnoreCase(result.getString("SP STR") )  && result.getInt("SP STR") > 0 )
                            || result.getInt("DIE QTY") > 0 || result.getInt("DIE STR") > 0 || result.getInt("FOL") > 0 || result.getInt("MOLD") > 0 || result.getInt("EOL") > 0
                            || result.getInt("F/G STR") > 0 ) )
                    {
                         assemblyLot = (AssemblyLot)m_assemblyDataMap.get( partNumber + lotNumber + fabLotNumber );

                         if (assemblyLot == null)
                         {
                             assemblyLot = new AssemblyLot( VENDOR_NAME_CARCEM, WIP_TYPE_ASSEMBLY );
                             m_assemblyDataMap.put( partNumber + lotNumber + fabLotNumber, assemblyLot);
                         }

                        if (result.getInt("QTY SHIP") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("QTY SHIP") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("QTY SHIP")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("QTY SHIP")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Shipped");
                            }
                            else
                            {
                                assemblyLot.setStage("Shipped");
                            }
                        }
                        if (result.getInt("B/G STR") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("B/G STR") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("B/G STR")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("B/G STR")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", BackGrind Store");
                            }
                            else
                            {
                                assemblyLot.setStage("BackGrind Store");
                            }
                        }

                        if (result.getInt("SB STR") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("SB STR") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("SB STR") + "");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("SB STR")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Scibe Break");
                            }
                            else
                            {
                                assemblyLot.setStage("Scibe Break");
                            }
                        }
                        if ( (!"C".equalsIgnoreCase(result.getString("SP STR") )  && result.getInt("SP STR") > 0  ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("SP STR") +"") + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("SP STR")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("SP STR")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Screen Print");
                            }
                            else
                            {
                                assemblyLot.setStage("Screen Print");
                            }
                        }

                        if (result.getInt("DIE QTY") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("DIE QTY")) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("DIE QTY")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("DIE QTY") +"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Die Qty");
                            }
                            else
                            {
                                assemblyLot.setStage("Die Qty");
                            }
                        }
                        if (result.getInt("DIE STR") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("DIE STR") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("DIE STR") +"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("DIE STR")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Die Store");
                            }
                            else
                            {
                                assemblyLot.setStage("Die Store");
                            }
                        }

                        if (result.getInt("FOL") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("FOL") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("FOL")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("FOL")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", FOL");
                            }
                            else
                            {
                                assemblyLot.setStage("FOL");
                            }
                        }

                        if ( result.getInt("MOLD") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("MOLD") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("MOLD")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("MOLD")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Molding");
                            }
                            else
                            {
                                assemblyLot.setStage("Molding");
                            }
                        }
                        if (result.getInt("EOL") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("EOL") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("EOL")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("EOL")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", EOL");
                            }
                            else
                            {
                                assemblyLot.setStage("EOL");
                            }
                        }
                        if ( result.getInt("F/G STR") > 0 )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fabLotNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + result.getInt("F/G STR") ) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(result.getInt("F/G STR")+"");
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(result.getInt("F/G STR")+"");
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", FG Store");
                            }
                            else
                            {
                                assemblyLot.setStage("FG Store");
                            }
                        }


                        if ( assemblyLot.getQtyIn() != null && !"0".equalsIgnoreCase( assemblyLot.getQtyIn() ))
                        {
                            assemblyLot.setDeviceName(partNumber);
                            assemblyLot.setLotNumber(lotNumber);
                            if ( result.getString("RMK") != null && result.getString("RMK").toUpperCase().indexOf("HOLD") != 1 )
                            {
                                assemblyLot.setStatus(LOT_STATUS_HOLD);
                                assemblyLot.setHoldReason(result.getString("RMK"));
                            }
                            else
                            {
                                assemblyLot.setStatus(LOT_STATUS_RUNNING);
                            }
                            assemblyLot.setPackageType(result.getString("PKG"));
                            assemblyLot.setFabLotNumber(fabLotNumber);
                            assemblyLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                            if ( result.getDate("DATE ISSUE") != null )
                            {
                                assemblyLot.setDateIn( StringUtils.formatDateToString(result.getDate("DATE ISSUE") ) );
                            }
                            
                            if ( result.getDate("DATE COMT") != null )
                            {
                                assemblyLot.setExpectedDateOut( StringUtils.formatDateToString(result.getDate("DATE COMT")) );
                            }
                            else
                            {
                                assemblyLot.setExpectedDateOut( StringUtils.formatDateToString(result.getDate("FORCST SHIP DTE") ) );
                            }
                         }
                    }
                }
            }
        }
        catch(Exception e )
        {
            e.printStackTrace();
            throw e;
        }
    }

    private void parseTestWipReport (String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ParserResult result            = null;

        InventoryLot inventoryLot  = null;
        TestLot      testLot       = null;
        CarsemWipStatus wipStatus  = null;
        String partNumber       = null;
        String lotNumber        = null;
        ArrayList<CarsemWipStatus>  dataList = null;

        try
        {
            File detailWipFile = new File( fileName );
            if ( !detailWipFile.exists() )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            Parser parser = ParserFactory.getJXLXLSParser( detailWipFile );
            log( "\nFound " + fileName );
            log( "\nParsing the file for TEST Wip Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for TEST WIP Report..." );

            ((JXLXLSParserImpl)parser).setHeaderRowIdx(4);
            ((JXLXLSParserImpl)parser).setDataStartRowIdx(5);

            result = parser.parse();

            while ( result.next() )
            {
                if ( result.getString("LOT NUMBER").indexOf("PACKAGE") != -1 || result.getString("LOT NUMBER").indexOf("DEVICE: Grand Total") != -1 )
                {
                    continue;
                }
                if ( result.getString("LOT NUMBER") != null && result.getString("LOT NUMBER").indexOf("DEVICE") == -1 )
                {
                    lotNumber  = result.getString("LOT NUMBER");
                    wipStatus = new CarsemWipStatus();

                    if ( lotNumber.indexOf("@") != -1 )
                    {
                        lotNumber = lotNumber.split("@")[0];
                    }
                    if ( dataList == null )
                    {
                        dataList = new ArrayList<CarsemWipStatus>();
                    }

                    wipStatus.setLotNumber( lotNumber );
                    wipStatus.setFabLotNumber( lotNumber );
                    wipStatus.setDateCode( result.getString("DATE CODE") );
                    wipStatus.setHoldStage( result.getString("HOLD STATE") );
                    wipStatus.setIqcQty( result.getInt("IQC") );
                    wipStatus.setPreTestQty( result.getInt("PRETEST"));
                    wipStatus.setTestQty( result.getInt("TEST"));
                    wipStatus.setTestQcQty( result.getInt("TEST QC"));
                    wipStatus.setBakeQty( result.getInt("BAKE"));
                    wipStatus.setFinhQty( result.getInt("FINH"));
                    wipStatus.setTestPartialQty( result.getInt("TEST PARTIAL"));
                    wipStatus.setOqaQty( result.getInt("OQA"));
                    wipStatus.setFgQty( result.getInt("FG"));
                    wipStatus.setReceiveDate(StringUtils.formatDate(result.getString("DATE RCVD"), "yyyy-MMM-dd", "MM/dd/yyyy" ) );
                    wipStatus.setIssueDate(StringUtils.formatDate(result.getString("DATE ISSUE"),"yyyy-MMM-dd", "MM/dd/yyyy" ) );
                    wipStatus.setCommitDate(result.getString("DATE COMMIT") );

                    dataList.add( wipStatus );
                }
                else if (result.getString("LOT NUMBER").indexOf("DEVICE") != -1  )
                {
                     partNumber = result.getString("LOT NUMBER").split(" ")[1] ;
					
                     m_partNumberMap.put( partNumber, dataList );
                    dataList = null;
                }
            }

            Iterator<String>  it = m_partNumberMap.keySet().iterator();
			
            while (it.hasNext() )
            {
                String partNo = (String)it.next();

				if ( partNo != null && m_partNumberMap.get(partNo) != null && m_partNumberMap.get(partNo).size() > 0 )
				{
				int value = m_partNumberMap.get(partNo).size();
                for ( int i=0; i < value; i++)
                {
                    wipStatus =(CarsemWipStatus) m_partNumberMap.get(partNo).get(i);

                    if ( wipStatus.getIqcQty() > 0 || wipStatus.getPreTestQty() > 0  )
                    {
                        int pretestProcessSepId = NewAdaptorDAO.getProcessStepId( partNo, LOCATION_TYPE_CLASS_STORE, LOCATION_TYPE_PRE_TEST );
                        if ( pretestProcessSepId <= 0 )
                        {
                            if ( partNo.indexOf("-TUS") != -1 )
                            {
                                partNo = partNo.substring(0, partNo.indexOf("-TUS") );
                            }
                            testLot = (TestLot)m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if ( testLot == null )
                            {
                                testLot = new TestLot( VENDOR_NAME_CARCEM, LOCATION_TYPE_FT );
                                m_testDataMap.put( partNo + wipStatus.getLotNumber(), testLot );
                            }

                            if (wipStatus.getIqcQty() > 0 )
                            {
                                testLot = (TestLot)m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                                if (testLot.getQtyIn() != null)
                                {
                                    try
                                    {
                                        testLot.setQtyIn( ( Integer.parseInt(testLot.getQtyIn()) + wipStatus.getIqcQty() ) +"" );
                                    }
                                    catch (Exception e)
                                    {
                                        testLot.setQtyIn(wipStatus.getIqcQty()+"");
                                    }
                                }
                                else
                                {
                                    testLot.setQtyIn(wipStatus.getIqcQty()+"");
                                }

                                if (testLot.getStage() != null)
                                {
                                    testLot.setStage(testLot.getStage() + ", IQC");
                                }
                                else
                                {
                                    testLot.setStage("IQC");
                                }
                            }
                            if (wipStatus.getPreTestQty() > 0 )
                            {
                                testLot = (TestLot)m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                                if (testLot.getQtyIn() != null)
                                {
                                    try
                                    {
                                        testLot.setQtyIn( ( Integer.parseInt(testLot.getQtyIn()) + wipStatus.getPreTestQty() ) +"" );
                                    }
                                    catch (Exception e)
                                    {
                                        testLot.setQtyIn(wipStatus.getPreTestQty()+"");
                                    }
                                }
                                else
                                {
                                    testLot.setQtyIn(wipStatus.getPreTestQty()+"");
                                }

                                if (testLot.getStage() != null)
                                {
                                    testLot.setStage(testLot.getStage() + ", PreTest");
                                }
                                else
                                {
                                    testLot.setStage("PreTest");
                                }
                            }

                            if ( testLot.getQtyIn() != null && !"0".equalsIgnoreCase( testLot.getQtyIn() ) )
                            {
                                testLot.setPartNumber( partNo );
                                testLot.setLotNumber( wipStatus.getLotNumber() );
                                testLot.setDateIn( wipStatus.getReceiveDate() );
                                testLot.setFabLotNumber( wipStatus.getLotNumber() );
                                if ( wipStatus.getHoldStage() != null && wipStatus.getHoldStage().trim().length() > 0 )
                                {
                                    testLot.setStatus( LOT_STATUS_HOLD );
                                    testLot.setHoldCode( wipStatus.getHoldStage() );
                                }
                                else
                                {
                                    testLot.setStatus( LOT_STATUS_RUNNING );
                                }
                                testLot.setDateCode( wipStatus.getDateCode() );
                                testLot.setExpecetedDate( wipStatus.getCommitDate() );
                                testLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                            }
                        } //If the PArt Number is Test Part Number
                        else
                        {
                            inventoryLot = (InventoryLot)m_preTestDataMap.get( partNo + wipStatus.getLotNumber() );

                            if ( inventoryLot == null )
                            {
                                inventoryLot = new InventoryLot( VENDOR_NAME_CARCEM, LOCATION_TYPE_PRE_TEST );
                                m_preTestDataMap.put( partNo + wipStatus.getLotNumber(), inventoryLot );
                            }

                            if (wipStatus.getIqcQty() > 0 )
                            {
                                inventoryLot = m_preTestDataMap.get( partNo + wipStatus.getLotNumber() );

                                if (inventoryLot.getQtyIn() != null)
                                {
                                    try
                                    {
                                        inventoryLot.setQtyIn( ( Integer.parseInt(inventoryLot.getQtyIn()) + wipStatus.getIqcQty() ) +"" );
                                    }
                                    catch (Exception e)
                                    {
                                        inventoryLot.setQtyIn(wipStatus.getIqcQty()+"");
                                    }
                                }
                                else
                                {
                                    inventoryLot.setQtyIn(wipStatus.getIqcQty()+"");
                                }

                                if (inventoryLot.getStage() != null)
                                {
                                    inventoryLot.setStage(inventoryLot.getStage() + ", IQC");
                                }
                                else
                                {
                                    inventoryLot.setStage("IQC");
                                }
                            }
                            if (wipStatus.getPreTestQty() > 0 )
                            {
                                inventoryLot = m_preTestDataMap.get( partNo + wipStatus.getLotNumber() );

                                if (inventoryLot.getQtyIn() != null)
                                {
                                    try
                                    {
                                        inventoryLot.setQtyIn( ( Integer.parseInt(inventoryLot.getQtyIn()) + wipStatus.getPreTestQty() ) +"" );
                                    }
                                    catch (Exception e)
                                    {
                                        inventoryLot.setQtyIn(wipStatus.getPreTestQty()+"");
                                    }
                                }
                                else
                                {
                                    inventoryLot.setQtyIn(wipStatus.getPreTestQty()+"");
                                }

                                if (inventoryLot.getStage() != null)
                                {
                                    inventoryLot.setStage(inventoryLot.getStage() + ", PreTest");
                                }
                                else
                                {
                                    inventoryLot.setStage("PreTest");
                                }
                            }

                            if ( inventoryLot.getQtyIn() != null && !"0".equalsIgnoreCase( inventoryLot.getQtyIn() ) )
                            {
                                inventoryLot.setPartNumber( partNo );
                                inventoryLot.setLotNumber( wipStatus.getLotNumber() );
                                inventoryLot.setDateIn( wipStatus.getReceiveDate() );
                                inventoryLot.setFabLotNumber( wipStatus.getLotNumber() );
                                if ( wipStatus.getHoldStage() != null && wipStatus.getHoldStage().trim().length() > 0 )
                                {
                                    inventoryLot.setStatus( LOT_STATUS_HOLD );
                                    inventoryLot.setHoldCode( wipStatus.getHoldStage() );
                                }
                                else
                                {
                                    inventoryLot.setStatus( LOT_STATUS_RUNNING );
                                }
                                inventoryLot.setDateCode( wipStatus.getDateCode() );
                                inventoryLot.setExpectedDate( wipStatus.getCommitDate() );
                                inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_PROD );
                            }
                        }
                    }// PRETEST

                    if ( wipStatus.getTestQty() > 0 || wipStatus.getTestQcQty()>0 || wipStatus.getTestPartialQty() > 0
                            || wipStatus.getFinhQty() > 0 || wipStatus.getOqaQty() > 0 || wipStatus.getFgQty() > 0 )
                    {
                        if ( partNo.indexOf("-TUS") != -1 )
                        {
                            partNo = partNo.substring(0, partNo.indexOf("-TUS") );
                        }
                        testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                        if (testLot == null)
                        {
                            testLot = new TestLot( VENDOR_NAME_CARCEM);
                            m_testDataMap.put( partNo + wipStatus.getLotNumber(), testLot);
                        }

                        if (wipStatus.getTestQty()  > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt(testLot.getQtyIn()) + wipStatus.getTestQty()  ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getTestQty() +"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getTestQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", TEST");
                            }
                            else
                            {
                                testLot.setStage("TEST");
                            }
                        }
                        if (wipStatus.getTestQcQty()  > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( (Integer.parseInt(testLot.getQtyIn()) + wipStatus.getTestQcQty() ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getTestQcQty()+"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getTestQcQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", Test QC");
                            }
                            else
                            {
                                testLot.setStage("Test QC");
                            }
                        }
                        if (wipStatus.getTestPartialQty() > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt(testLot.getQtyIn()) + wipStatus.getTestPartialQty() ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getTestPartialQty()+"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getTestPartialQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", Test Partial");
                            }
                            else
                            {
                                testLot.setStage("Test Partial");
                            }
                        }
                        if (wipStatus.getFinhQty() > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( (Integer.parseInt(testLot.getQtyIn()) + wipStatus.getFinhQty() ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getFinhQty()+"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getFinhQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", FINH");
                            }
                            else
                            {
                                testLot.setStage("FINH");
                            }
                        }
                        if (wipStatus.getOqaQty() > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( (Integer.parseInt(testLot.getQtyIn()) + wipStatus.getOqaQty() ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getOqaQty()+"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getOqaQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", OQA");
                            }
                            else
                            {
                                testLot.setStage("OQA");
                            }
                        }
                        if (wipStatus.getFgQty() > 0 )
                        {
                            testLot = m_testDataMap.get( partNo + wipStatus.getLotNumber() );

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn( (Integer.parseInt(testLot.getQtyIn()) + wipStatus.getFgQty() ) +"" );
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(wipStatus.getFgQty()+"");
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(wipStatus.getFgQty()+"");
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", FG");
                            }
                            else
                            {
                                testLot.setStage("FG");
                            }
                        }
                        if ( testLot.getQtyIn() != null && !"0".equalsIgnoreCase( testLot.getQtyIn() ) )
                        {
                            testLot.setLotNumber( wipStatus.getLotNumber() );
                            testLot.setPartNumber( partNo );
                            if ( wipStatus.getHoldStage() != null && wipStatus.getHoldStage().trim().length() > 0 )
                            {
                                testLot.setStatus( LOT_STATUS_HOLD );
                                testLot.setHoldReason( wipStatus.getHoldStage());
                            }
                            else
                            {
                                testLot.setStatus( LOT_STATUS_RUNNING );
                            }
                            testLot.setFabLotNumber( wipStatus.getLotNumber() );
                            testLot.setPsType( LOCATION_TYPE_FT );
                            testLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                            if ( wipStatus.getIssueDate() != null )
                            {
                                testLot.setDateIn( wipStatus.getIssueDate() );
                            }
                            else
                            {
                                testLot.setDateIn( wipStatus.getReceiveDate() );
                            }
                            testLot.setDateCode( wipStatus.getDateCode() );
                            if ( wipStatus.getCommitDate() != null )
                            {
                                testLot.setExpecetedDate( wipStatus.getCommitDate() );
                            }
                        }
                    }

                    }
				}
				else
				{
					System.out.println("IN ELSE PART NO" + partNo );
				}

            }
        }
        catch(Exception e )
        {
            e.printStackTrace();
            throw e;
        }
    }

    private void log( String message )
    {
      if ( message == null ) return;

      if ( m_parserLogger != null )
      {
          m_parserLogger.logDebug( message + LINE_SEPARATOR );
      }
      else
      {
          System.out.println( message );
      }
    } // end of log method

}
